//
//  QuDanUserCetnerTopView.m
//  QuDanOEM
//
//  Created by xiaohuang on 2021/11/21.
//

#import "QuDanUserCetnerTopView.h"

@interface QuDanUserCetnerTopView ()

@property (nonatomic,strong)UIButton *leftBtn;

@property (nonatomic,strong)UIButton *moreBtn;

@end

@implementation QuDanUserCetnerTopView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupuI];
    }
    return self;
}

- (UIButton *)leftBtn
{
    if (!_leftBtn) {
        _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_leftBtn setImage:[UIImage imageNamed:@"user_left"] forState:UIControlStateNormal];
        [_leftBtn addTarget:self action:@selector(actionLeftBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _leftBtn;
}

- (UIButton *)moreBtn
{
    if (!_moreBtn) {
        _moreBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_moreBtn setImage:[UIImage imageNamed:@"user_more"] forState:UIControlStateNormal];
        [_moreBtn addTarget:self action:@selector(actionRightBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _moreBtn;
}
-(void)actionRightBtn:(UIButton *)btn
{
    NSLog(@"right  btn");
    if (self.QuDanUserCetnerTopViewRightBlock) {
        self.QuDanUserCetnerTopViewRightBlock();
    }
}
-(void)actionLeftBtn:(UIButton *)btn
{
    NSLog(@"left btn");
    if (self.QuDanUserCetnerTopViewLeftBlock) {
        self.QuDanUserCetnerTopViewLeftBlock();
    }
}
-(void)setupuI
{
    [self addSubview:self.leftBtn];
    [self.leftBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self).offset(Height_StatusBar/2);
        make.left.offset(15);
        make.width.offset(60);
        make.height.offset(30);
    }];
    [self addSubview:self.moreBtn];
    [self.moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftBtn);
        make.right.offset(-15);
        make.width.offset(60);
        make.height.offset(30);
    }];
}
@end
